package io.file;

import java.io.File;
import java.io.FilenameFilter;

public class FileDemo2 {

    public static boolean renameTo(String bassDir, FilenameFilter filenameFilter, String regx, String replacement) {
        File file=new File(bassDir);
        File[] files=file.listFiles(filenameFilter);
        boolean result=true;
        for (File file1 : files) {
            String name=file1.getName();
            name=name.replaceAll(regx,replacement);
            result=file1.renameTo(new File(bassDir+"/"+name));
        }
        return result;
    }
}
